<?php
/**
 * Created by PhpStorm.
 * User: Admin
 * Date: 2020-08-02
 * Time: 下午 02:55
 */
namespace Lib;

/**
 * Class Server
 * @package Lib
 * 
 * @property \Lib\Functions $fh
 */
class Server extends Injector {
    public function requestPath() {
        $uri = $this->requestUri();
        $pos = strpos($uri, '?');
        
        if($pos === false) {
            return  $this->fh->formatPath($uri);
        } else {
            return $this->fh->formatPath(substr($uri, 0, $pos));
        }
    }
    
    public function user() {
        return $_SERVER['USER'];
    }

    public function home() {
        return $_SERVER['HOME'];
    }

    public function httpCookie() {
        return $_SERVER['HTTP_COOKIE'];
    }

    public function httpAcceptLanguage() {
        return $_SERVER['HTTP_ACCEPT_LANGUAGE'];
    }

    public function httpAcceptEncoding() {
        return $_SERVER['HTTP_ACCEPT_ENCODING'];
    }

    public function httpAccept() {
        return $_SERVER['HTTP_ACCEPT'];
    }

    public function httpUserAgent() {
        return $_SERVER['HTTP_USER_AGENT'];
    }

    public function httpUpgradeInsecureRequests() {
        return $_SERVER['HTTP_UPGRADE_INSECURE_REQUESTS'];
    }

    public function httpCacheControl() {
        return $_SERVER['HTTP_CACHE_CONTROL'];
    }

    public function httpConnection() {
        return $_SERVER['HTTP_CONNECTION'];
    }

    public function httpHost() {
        return $_SERVER['HTTP_HOST'];
    }

    public function redirectStatus() {
        return $_SERVER['REDIRECT_STATUS'];
    }

    public function serverName() {
        return $_SERVER['SERVER_NAME'];
    }

    public function serverPort() {
        return $_SERVER['SERVER_PORT'];
    }

    public function serverAddr() {
        return $_SERVER['SERVER_ADDR'];
    }

    public function remotePort() {
        return $_SERVER['REMOTE_PORT'];
    }

    public function remoteAddr() {
        return $_SERVER['REMOTE_ADDR'];
    }

    public function serverSoftware() {
        return $_SERVER['SERVER_SOFTWARE'];
    }

    public function gatewayInterface() {
        return $_SERVER['GATEWAY_INTERFACE'];
    }

    public function requestScheme() {
        return $_SERVER['REQUEST_SCHEME'];
    }

    public function serverProtocol() {
        return $_SERVER['SERVER_PROTOCOL'];
    }

    public function documentRoot() {
        return $_SERVER['DOCUMENT_ROOT'];
    }

    public function documentUri() {
        return $_SERVER['DOCUMENT_URI'];
    }

    public function requestUri() {
        return $_SERVER['REQUEST_URI'];
    }

    public function scriptName() {
        return $_SERVER['SCRIPT_NAME'];
    }

    public function contentLength() {
        return $_SERVER['CONTENT_LENGTH'];
    }

    public function contentType() {
        return $_SERVER['CONTENT_TYPE'];
    }

    public function requestMethod() {
        return $_SERVER['REQUEST_METHOD'];
    }

    public function queryString() {
        return $_SERVER['QUERY_STRING'];
    }

    public function scriptFilename() {
        return $_SERVER['SCRIPT_FILENAME'];
    }

    public function pathInfo() {
        return $_SERVER['PATH_INFO'];
    }

    public function fcgiRole() {
        return $_SERVER['FCGI_ROLE'];
    }

    public function phpSelf()
    {
        return $_SERVER['PHP_SELF'];
    }
}
